package com.example.dubbotest.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.example.dubbotest.api.HelloService;
import com.example.dubbotest.api.pojo.TableA;
import com.example.dubbotest.api.pojo.TableB;
import com.example.dubbotest.service.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class HelloServiceImpl implements HelloService{

    @Autowired
    UserMapper userMapper;

    @Override
    public String tellMe() {

        try {
            Thread.sleep(25000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return "呵呵 嗷嗷嗷嗷啊啊";
    }

    @Override
    @Transactional
    public List<Map<String, Object>> listAll() throws Exception {

        TableA a = new TableA();
        a.setName("sdfasd");
        a.setAge(212);
        userMapper.insertA(a);

        System.out.println(1/0);

        TableB b = new TableB();
        b.setName("sdfasdf");
        b.setAge(200);
        userMapper.insertB(b);

        return userMapper.listAll();
    }

}
